package collection;

import java.util.*;

public class Test {
    public static void main(String args[]){
        HashMap<Teacher,Course> mp=new HashMap<>();

        Teacher swk=new Teacher("孙悟空",1,500);
        Teacher zbj=new Teacher("猪八戒",2,700);
        Teacher ts=new Teacher("唐僧",3,60);
        Teacher swj=new Teacher("沙悟净",4,400);

        Course ai=new Course("人工智能","computer01");
        Course sjk=new Course("数据库原理","computer02");
        Course sf=new Course("算法分析","computer03");

        mp.put(swk,ai);
        mp.put(zbj,sjk);
        mp.put(ts,sf);
        mp.put(swj,sjk);

        for(Teacher th:mp.keySet()){
            System.out.println(th.name+" "+mp.get(th).courseName);
        }

        System.out.println("------------------------");

        Collection values1=mp.values();
        for(Object e:values1){
            Course c=new Course();
            c=(Course) e;
            System.out.println(c.getCourseName());
        }

        System.out.println("------------------------");

        Set<Map.Entry<Teacher,Course>>entries=mp.entrySet();

        for(Map.Entry<Teacher,Course>e:entries){
            Teacher t=e.getKey();
            Course c=e.getValue();
            System.out.println(t.getName()+" "+c.getCourseName());
        }

    }
}
